package org.elanfox.intellicommunity.msg.dto;

import lombok.Data;
import lombok.NoArgsConstructor;
import org.elanfox.intellicommunity.msg.base.CmdStatus;
import org.elanfox.intellicommunity.msg.ienum.CmdEnums;

import java.io.Serializable;

/**
 * 一条指令
 *
 * @author allan
 * @version 1.0.0
 * @date 2020/3/19
 */
@Data
@NoArgsConstructor
public class CmdDTO implements Serializable {
    private static final long serialVersionUID = 4491397689152459366L;
    /**
     * 指令代码
     */
    private CmdEnums.Code cmdCode;
    /**
     * 基站id
     */
    private Integer stationId;
    /**
     * 阅读器地址
     */
    private String hexAddr;
    /**
     * read结果
     */
    private RawMsgDTO rawMsgDTO;
    /**
     * write参数
     */
    private CmdWriteParam cmdWriteParam;
    /**
     * 指令状态
     */
    private CmdStatus cmdStatus;

    public CmdDTO(CmdEnums.Code cmdCode, CmdWriteParam cmdWriteParam, Integer stationId) {
        this.cmdCode = cmdCode;
        this.hexAddr = cmdWriteParam.getHexAddr();
        this.cmdWriteParam = cmdWriteParam;
        this.cmdStatus = new CmdStatus(CmdEnums.Status.IN_EXECUTION);
        this.stationId = stationId;
    }
}
